<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: lxf
  Date: 2017/7/7
  Time: 16:25
  To change this template use Editor | File and Code Templates.
--%>
<html>
<head>
    <title>日期时间选择器Demo</title>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css"
          rel="stylesheet">
    <script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/moment.js/2.18.1/moment.min.js"></script>
    <script src="http://cdn.bootcss.com/moment.js/2.18.1/locale/zh-cn.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<div style="margin:50px 45%">
    <form action="concurrentNumberManager.jsp" method="post" onsubmit="return checkForm()">
        <input type="hidden" name="queryType" id="queryType"/>
        <label class="control-label">公司ID：</label>
        <div class="input-group date" style="width: 220px">
            <input class="form-control" name="companyId" id="companyId" placeholder="00"/>
            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-pencil"></span>
                </span>
        </div>
        <div class="form-group">
            <label class="control-label">日期：</label>
            <div class="input-group date" style="width: 220px">
                <input class="form-control" name="expireTime" id="expireTime" placeholder="yyyy-MM-dd HH:mm:ss"/>
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
            </div>
            <label class="control-label">并发数：</label>
            <div class="input-group date" style="width: 220px">
                <input class="form-control" name="concurrenceNumber" id="concurrenceNumber" placeholder="00"/>
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-pencil"></span>
                </span>
            </div>
        </div>
        <input class="btn btn-primary" type="submit" value="生成sql">
    </form>

</div>
<div>
    <span id="showSql"></span>
</div>
<script type="text/javascript">
    $(function () {
        $("#expireTime").datetimepicker({
            locale: 'zh-cn',
            format: 'YYYY-MM-DD HH:mm:ss'
        });
    });

    function checkForm() {
        var expireTime = $("#expireTime").val();
        var number = $("#concurrenceNumber").val();
        var companyId = $("#companyId").val();

        if (!/^(0|[1-9][0-9]*)$/ig.test(companyId)) {
            $("#companyId").focus();
            alert('请输入非零开头的公司ID!');
            return false;
        }

        if (expireTime == '') {
            $("#expireTime").focus();
            alert("请选择过期时间!");
            return false;
        }

        if (!/^(0|[1-9][0-9]*)$/ig.test(number)) {
            $("#concurrenceNumber").focus();
            alert('请输入非零开头的并发数!');
            return false;
        }
        $("#queryType").val("1");
        return true;
    }


</script>
</body>
</html>
